package com.yanqu.road.server.cmd.activity.snowgarden;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.SnowGardenProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C_SNOW_GARDEN_VISITED, desc = "冰雪游园拜访")
public class SnowGardenVisitCrossCmd extends CrossCommand {
    private int activityId;
    private long userId;
    private long serverId;
    private long targetUserId;
    private long targetServerId;
    private int visitType;
    private String visitParam;
    private long recordTime;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        SnowGardenProto.SnowGardenToCrossVisitReqMsg req = SnowGardenProto.SnowGardenToCrossVisitReqMsg.parseFrom(packet.getBytes());
        activityId = req.getActivityId();
        userId = req.getUserId();
        serverId = req.getUserServerId();
        targetUserId = req.getTargetUserId();
        targetServerId = req.getTargetServerId();
        visitType = req.getVisitType();
        visitParam = req.getVisitParam();
        recordTime = req.getRecordTime();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        SnowGardenProto.SnowGardenToCrossVisitReqMsg.Builder msg = SnowGardenProto.SnowGardenToCrossVisitReqMsg.newBuilder();
        msg.setActivityId(activityId);
        msg.setUserId(userId);
        msg.setUserServerId(serverId);
        msg.setTargetUserId(targetUserId);
        msg.setTargetServerId(targetServerId);
        msg.setVisitType(visitType);
        msg.setVisitParam(visitParam);
        msg.setRecordTime(recordTime);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_SNOW_GARDEN_CROSS_VISIT, msg);
        MessageHelper.sendPacket(targetServerId, targetUserId, message);
    }

    @Override
    public void sendData() {

    }
}
